<?php

namespace app\common\validate;

use think\Validate;

class Guess extends Validate {

    protected $rule = [
        'guess_16' => 'checkguess_16:guess_16|require',
        'guess_8' => 'require',
        'guess_4' => 'require',
        'guess_1' => 'require',
        'guess_3' => 'require',
        'guess_first' => 'require',
        'guess_three' => 'require',
        'count' => 'number|between:1,100',
        'page' => 'number',
        'guess_img'=>'require',
        'mobile'=>'require|regex:(1[3-8])[0-9]{9}|length:11'
    ];
    protected $field = [
        'guess_16' => '16强对阵',
        'guess_8' => '8强对阵',
        'guess_4' => '4强对阵',
        'guess_3' => '第三名对阵',
        'guess_1' => '冠军争夺',
        'guess_first' => '冠军',
        'guess_three' => '第三名',
        'guess_img' => '冠军推演图',
        'page'=>'',
        
    ];
    protected $scene = [

        'add' => ['guess_16', 'guess_8', 'guess_4', 'guess_3', 'guess_1', 'guess_three', 'guess_first','guess_img'],
        'pointlist' => ['count', 'page'],
        'firstlist' => ['count', 'page'],
         'savemobile' => ['mobile'],
    ];

    // 自定义验证规则
    protected function checkguess_16($value, $rule, $data) {
        $count = count(explode(";", $value));
        if ($count == 16) {
            return true;
        } else {
            return '请选择16强完整对阵';
        }
    }

    // 自定义验证规则
    protected function checkguess_8($value, $rule, $data) {
        $count = count(explode(";", $value));
        if ($count == 8) {
            return true;
        } else {
            return '请选择8强完整对阵';
        }
    }

    // 自定义验证规则
    protected function checkguess_4($value, $rule, $data) {
        $count = count(explode(";", $value));
        if ($count == 4) {
            return true;
        } else {
            return '请选择4强完整对阵';
        }
    }

}
